package com.bw.service.impl;

import com.bw.dao.CustomerDao;
import com.bw.dao.impl.CustomerDaoImpl;
import com.bw.pojo.vo.CustomerVo;
import com.bw.service.CustomerService;
import com.bw.util.MyBatisUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class CustomerServiceImpl implements CustomerService {
    SqlSessionFactory sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
    CustomerDaoImpl dao = new CustomerDaoImpl();
    @Override
    public PageInfo<CustomerVo> getCustomerList(CustomerVo customerVo) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        CustomerDao customerMapper = sqlSession.getMapper(CustomerDao.class);
        PageHelper.startPage(customerVo.getPageNum(), customerVo.getPageSize());
        List<CustomerVo> list = customerMapper.getCustomerList(customerVo);
        PageInfo<CustomerVo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
